package ro.cityprojects.adminloc.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import ro.cityprojects.adminloc.entities.Entrance;
import ro.cityprojects.adminloc.exceptions.ValidationException;
import ro.cityprojects.adminloc.service.EntranceService;

/**
 * EntranceController
 *
 * @author bogdan.solga
 *
 * Date: 17.10.2013, time: 12:16
 */
@Controller
@RequestMapping(value = "/entrances")
public class EntranceController extends BaseController<Integer, Entrance> {

    @Autowired
    private EntranceService entranceService;

    @Override
    public void save(Entrance entrance) throws ValidationException {
        entranceService.save(entrance);
    }

    @Override
    public String get(@PathVariable Integer primaryKey, @RequestParam(required = false) String includedFields) {
        return entranceService.get(primaryKey, includedFields);
    }

    @Override
    public String get(@RequestParam(required = false) String name, @RequestParam(required = false) String value,
                      @RequestParam(required = false) String includedFields) {
        return entranceService.getAll(name, value, includedFields);
    }

    @Override
    public void update(Entrance entrance, Integer primaryKey) {
        entranceService.update(entrance, primaryKey);
    }

    @Override
    public void delete(Integer primaryKey) {
        entranceService.delete(primaryKey);
    }

    @Override
    public String getMetadata() {
        return entranceService.getMetadata();
    }
}
